using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web;

namespace jzlib.asp.net.Controls
{
    public class RadioColumItemTemplate:ITemplate   
    {
      
        public static string RadioButtonItemId
        {
            get
            {
                return "RadioColumnItem";
            }
        }
      
        public void InstantiateIn(Control container)
        {
            HtmlGenericControl l = new HtmlGenericControl();
            l.DataBinding += new EventHandler(l_DataBinding);           
            container.Controls.Add(l);
        }

        void l_DataBinding(object sender, EventArgs e)
        {
            HtmlGenericControl l = sender as  HtmlGenericControl;
            if (l != null)
            {
                GridViewRow row = (GridViewRow)l.NamingContainer;
                l.InnerHtml = "<input type='radio' name='" + RadioButtonItemId + "' value='" + row.DataItemIndex + "'/>";
            }
        }       
    }
}
